//
//  MyNotificationCell.m
//  xpkc
//
//  Created by TopSageOSX on 14-8-22.
//  Copyright (c) 2014年 wanmeizty. All rights reserved.
//

#import "MyNotificationCell.h"

@implementation MyNotificationCell{
    UIView *readFlagView;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self creatCellView];
    }
    return self;
}
/**
 *  创建视图
 */
-(void)creatCellView{
    //设定位置
    CGFloat offsize = 0.03*SCREEN_WIDTH;
    CGRect bg_frame;
    CGRect flag_frame;
    CGRect title_frame;
    CGRect time_frame;
    CGRect content_frame;
    CGRect line_frame,text_frame,right_frame;
    if (isPad) {
       
        bg_frame = RECT(-1, offsize, SCREEN_WIDTH+2, 150-offsize);
        flag_frame = RECT(bg_frame.size.width-20, 0, 20, 20);
        title_frame = RECT(offsize, offsize, bg_frame.size.width-offsize*2, 30);
        content_frame = RECT(offsize, 40, bg_frame.size.width-offsize*2, 35);
        time_frame = RECT(SCREEN_WIDTH - 200, 90, 200-offsize, 20);
        line_frame = RECT(offsize, 110, bg_frame.size.width-offsize*2, 0.5);
        text_frame = RECT(offsize, 110, 160, 40-offsize);
        right_frame = RECT(bg_frame.size.width-offsize*2, 130-offsize, offsize, offsize);
    }else{
        bg_frame = RECT(-1, offsize, SCREEN_WIDTH+2, 150-offsize);
        flag_frame = RECT(bg_frame.size.width-20, 0, 20, 20);
        title_frame = RECT(offsize, offsize, bg_frame.size.width-offsize*2, 30);
        content_frame = RECT(offsize, 50, bg_frame.size.width-offsize*2, 40);
        time_frame = RECT(SCREEN_WIDTH - 300, 90, 300-offsize, 20);
        line_frame = RECT(offsize, 110, bg_frame.size.width-offsize*2, 0.5);
        text_frame = RECT(offsize, 110, 160, 40-offsize);
        right_frame = RECT(bg_frame.size.width-offsize*2, 130-offsize, offsize*2/3, offsize);
    }

    //创建控件
    self.backgroundColor = BGColor;
    
    UIView *bgView = [[UIView alloc]initWithFrame:bg_frame];
    bgView.backgroundColor = [UIColor whiteColor];
    bgView.clipsToBounds = YES;
    bgView.layer.borderWidth = 1;
    bgView.layer.borderColor = [UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:0.3].CGColor;
    [self addSubview:bgView];
    
    
    self.title = [[UILabel alloc]init];
    self.title.frame = title_frame;
    self.title.font = FONT_BOLD(18);
    self.title.backgroundColor = [UIColor clearColor];
    [bgView addSubview:self.title];
    
    readFlagView = [[UIView alloc]initWithFrame:flag_frame];
    UIImageView *readflag = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, flag_frame.size.width, flag_frame.size.height)];
    readflag.image = [UIImage imageNamed:@"msg_read_flag"];
    [readFlagView addSubview:readflag];
    [bgView addSubview:readFlagView];
    
    self.time = [[UILabel alloc]init];
    self.time.frame = time_frame;
    self.time.font = FONT_SYS_XS;
    self.time.textAlignment = NSTextAlignmentRight;
    self.time.textColor = [UIColor lightGrayColor];
    self.time.backgroundColor = [UIColor whiteColor];
    [bgView addSubview:self.time];
    
    
    self.content = [[UILabel alloc]init];
    self.content.frame = content_frame;
    self.content.textColor = [UIColor lightGrayColor];
    self.content.font = FONT_SYS_S;
    self.content.numberOfLines = 0;
    self.content.backgroundColor = [UIColor whiteColor];
    [bgView addSubview:self.content];
    
    
    UIView *line = [[UIView alloc]initWithFrame:line_frame];
    line.layer.borderWidth = 0.5;
    line.layer.borderColor = [UIColor lightGrayColor].CGColor;
    line.alpha = 0.5;
    [bgView addSubview:line];
    
    
    UILabel *text = [[UILabel alloc]initWithFrame:text_frame];
    text.text = @"立即查看";
    text.font = FONT_SYS_S;
    text.textColor = [UIColor redColor];
    [bgView addSubview:text];
    
    
    UIImageView *right = [[UIImageView alloc]initWithFrame:right_frame];
    right.image = [UIImage imageNamed:@"rightsign@2x"];
    [bgView addSubview:right];
}

- (void)setRead:(BOOL)read{
    readFlagView.hidden = read;
//    logdebug(@"readdddd");
}
- (BOOL)read{
    return NO;
}



- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
